package xyz.yq56.easytool.utils.robot;

import java.awt.MouseInfo;
import java.awt.PointerInfo;
import java.util.concurrent.TimeUnit;

import xyz.yq56.easytool.utils.thread.ThreadUtil;

/**
 * 获取屏幕坐标,启动之后鼠标移动到指定位置即可打印坐标
 *
 * @author yiqiang
 */
public class MousePointer {

    public static void main(String[] args) {
        getPointInfo();
    }

    private static void getPointInfo() {
        int x = 0;
        int y = 0;
        while (true) {
            PointerInfo info = MouseInfo.getPointerInfo();
            int mx = info.getLocation().x;
            int my = info.getLocation().y;
            if (x != mx || y != my) {
                x = mx;
                y = my;
                System.out.println("x:" + mx + ",y:" + my);
            }
            ThreadUtil.sleep(1000, TimeUnit.MILLISECONDS);
        }
    }

}
